<template>
   <div class="fenlei">
        <swiper :options="swiperOption" class="swiper-box">
            <swiper-slide class="swiper-item">
              <one-array :dataonearray="dataonearray"></one-array>
            </swiper-slide>
            <swiper-slide class="swiper-item">
            dads
            </swiper-slide>
            <swiper-slide class="swiper-item">
               dadas
            </swiper-slide>
          <div class="swiper-pagination" :class="left1" slot="pagination" @touchstart.stop="">
          </div>
        </swiper>
         
   </div>
</template>

<script>
  import {swiper, swiperSlide} from 'vue-awesome-swiper'
  import oneArray from './oneArray'
  const TAB_NAME = ['一小时达', '生鲜预定','精选超时'];
  export default {
    data(){
        return {
            left1:'active-0',
            dataonearray:'',
            datafresh:'',
            datasupermarket:'',
            swiperOption: {
              pagination: '.swiper-pagination',
              paginationClickable: true,
              paginationBulletRender(swiper, index, className) {
                return  `<span class="${className} swiper-pagination-bullet-custom" style="
                  width:33.33%; height:40px;line-height:40px;font-size:12px; display:inline-block; margin:0;background-color:#fff; 
                ">${TAB_NAME[index]}</span>`;
              },
              onTransitionStart: swiper => {
                this.left1 = 'active-'+swiper.realIndex;
              }
            }
        }
      },
      methods: {
        
      },
      components: {
        swiper,
        swiperSlide,
        oneArray
      },
      created:function(){
         this.$http.jsonp('http://shopping-snxd.suning.com/cmwspds-web/catalog/getCatalog/910D_catalog.jsonp', {
            params: {
              _: Math.random()+10000000,
            },
            jsonp: 'callback',
            jsonpCallback: 'catalog'
          }).then((rep) => {
            let alldata = rep.data.responseObject;
            if(rep.ok){
              this.dataonearray = alldata.oneHourUp;
              
              this.datafresh = alldata.freshBook;
              this.datasupermarket = alldata.superMarket;
            }
          })
      }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="less" scoped>
  
  .swiper-box {
    width: 100%;
    height: 100%;
    margin: 0 auto;
  }

  .swiper-item {
    height: 100%;
  }

  .swiper-pagination-bullet-custom {
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    text-align: center;
    line-height: 50px;
    color: #999999;
    border-radius: 0 !important;
    background: #fff !important;
    opacity: 1 !important;
  }
.swiper-wrapper {
  touch-action: none;
  height: 100%;
}
.swiper-container {
  overflow: visible !important;
  position: fixed !important; 
  top:41px;
  bottom:45px !important;
  height: auto !important;
  
}
.swiper-pagination {
  position: fixed;
  width: 100% !important;
  top:0;
  bottom: auto;
  height: 40px;
  background-color: #fff;
  z-index: 11;
}
.swiper-pagination-bullet {
  height: 40px !important;
  line-height: 40px !important;
  width: 33.33% !important;
  color:#000;
  font-size: 12px;
  touch-action: none;
}
.swiper-pagination {
  
  &:after {
    position: absolute;
    transition:all 0.3s;
    content: "";
    width:20%;
    height: 2px;
    background-color: red;
    bottom:0;
    left: 7%;
  }
}
.active-0{
  &:after {
    left: 7%;
  }
}
.active-1{
  &:after {
    left: 40%;
  }
}
.active-2{
  &:after {
    left: 74%;
  }
}
</style>
